﻿package mortal.game.view.common.guide.view
{
    import com.gengine.global.*;
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.component.window.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.guide.data.*;

    public class AutoGuidePictureWin extends BaseWindow
    {
        private var _bmp:GBitmap;
        private var _btn:GButton;
        private var _timer:Timer;
        private var _data:AutoGuideData;
        private var _callback:Function;
        public static const Click_Isee:int = 1;
        public static const Click_Timer:int = -1;

        public function AutoGuidePictureWin()
        {
            this.setSize(398, 304);
            return;
        }// end function

        public function set autoGuideData(param1:AutoGuideData) : void
        {
            this._data = param1;
            LoaderManager.instance.load(this._data.guideTypeValue + ".swf", this.onLoaded);
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(Global.stage.stageWidth / 2 + 110, 140);
            return;
        }// end function

        private function onLoaded(param1:SWFInfo) : void
        {
            if (isDisposed)
            {
                return;
            }
            this._bmp.bitmapData = param1.bitmapData;
            if (this._timer == null)
            {
                this._timer = new Timer(parseInt(this._data.clickChildName));
                this._timer.addEventListener(TimerEvent.TIMER, this.timerHandler);
            }
            this._timer.start();
            return;
        }// end function

        private function timerHandler(event:TimerEvent) : void
        {
            if (this._callback != null)
            {
                this._callback.apply(null, [Click_Timer]);
            }
            this.hide();
            return;
        }// end function

        private function clickISeeHandler(event:MouseEvent) : void
        {
            if (this._callback != null)
            {
                this._callback.apply(null, [Click_Isee]);
            }
            this.hide();
            return;
        }// end function

        public function set callback(param1:Function) : void
        {
            this._callback = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bmp = UIFactory.gBitmap("", 12, 40, this);
            this._btn = UIFactory.gButton(Language.getString(20719), 163, 263, 80, 24, this);
            this._btn.configEventListener(MouseEvent.CLICK, this.clickISeeHandler);
            DisplayUtil.removeMe(_closeBtn);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bmp.dispose(param1);
            this._bmp = null;
            this._btn.dispose(param1);
            this._btn = null;
            if (this._timer != null)
            {
                this._timer.stop();
                this._timer = null;
            }
            this._callback = null;
            return;
        }// end function

    }
}
